Skip to content

Upgrade to v0.2.0 - #27

Merged
rsoury merged 11 commits into
masterfrom
develop
Feb 19, 2026
Merged

Upgrade to v0.2.0#27
rsoury merged 11 commits into
masterfrom
develop

Conversation

@rsoury

@rsoury rsoury commented Feb 19, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

Release Notes

  • New Features

    • Policy configuration now supports multiple per-exchange, per-network withdraw rules with intelligent prioritization.
    • Enhanced order validation with market pattern matching and execution resolution.
    • OpenTelemetry logging integration via LogLayer framework.
    • Dev container initialization for git worktree support.
  • Documentation

    • Added comprehensive POLICY.md guide.
    • Updated README with new policy structure examples.
  • Chores

    • Version bumped to 0.2.0.
    • Updated dependencies including OpenTelemetry stack and LogLayer packages.

victorshevtsov and others added 11 commits February 4, 2026 08:46
…stments

- Added an initialization script (.devcontainer/init.sh) to determine the main repository path when in a git worktree.
- Updated docker-compose.yml to include a volume workaround for accessing the main repo path.
- Set the entrypoint script (.devcontainer/entrypoint.sh) to be executable.
- Included an initializeCommand in devcontainer.json to run the new script on container startup.
Upgrade Policy Engine and JSON Format. Improve Otel for log shipping
@rsoury
rsoury merged commit c121488 into master Feb 19, 2026
4 of 5 checks passed
@coderabbitai

coderabbitai Bot commented Feb 19, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between c85517a and 3a6d014.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (25)
  • .devcontainer/devcontainer.json
  • .devcontainer/docker-compose.yml
  • .devcontainer/init.sh
  • .sandbox/Dockerfile
  • POLICY.md
  • README.md
  • biome.json
  • examples/kraken-orderbook-demo.ts
  • package.json
  • policy/policy.json
  • scripts/gen-descriptor.ts
  • src/client.dev.ts
  • src/helpers/index.test.ts
  • src/helpers/index.ts
  • src/helpers/logger.ts
  • src/helpers/otel.ts
  • src/index.ts
  • src/server.ts
  • src/types.ts
  • test/cex-broker.test.ts
  • test/helpers.test.ts
  • test/index.test.ts
  • test/integration.test.ts
  • test/otel.test.ts
  • test/start-broker.test.ts

Walkthrough

This PR restructures policy validation from a single withdraw rule to an array of exchange/network-scoped rules, introduces OpenTelemetry logging via LogLayer with multiple transports, adds market pattern matching and order execution resolution logic, and expands test coverage significantly.

Changes

Cohort / File(s) Summary
Dev Container & Initialization
.devcontainer/devcontainer.json, .devcontainer/docker-compose.yml, .devcontainer/init.sh, .sandbox/Dockerfile
Added dev container initialization script to detect git worktrees and propagate MAIN_REPO environment variable; updated Dockerfile to bump cex-broker package version from 0.1.21 to 0.2.0.
Documentation
POLICY.md, README.md
Added comprehensive POLICY.md reference documentation for policy.json configuration, validation rules, and hot-reload behavior; updated README with new array-based rule policy structure examples and removed legacy composite amounts/networks format.
Configuration
biome.json, package.json
Added experimental scanner ignore pattern for proto files; bumped version to 0.2.0 and added OpenTelemetry logging dependencies (@loglayer/\*, @opentelemetry/api-logs, @opentelemetry/exporter-logs-otlp-http, @opentelemetry/sdk-logs) plus loglayer and serialize-error packages.
Policy Types & Schema
src/types.ts, policy/policy.json
Refactored WithdrawRule to WithdrawRuleEntry with exchange and network fields; changed PolicyConfig.withdraw.rule from single object to array of entries; made OrderRule.limits optional; updated example policy.json to use discrete per-exchange rules.
Policy Validation & Helpers
src/helpers/index.ts
Implemented exchange/network-scoped withdraw rule prioritization; added market pattern matching and resolveOrderExecution for market symbol/side resolution; enhanced policy normalization and error handling; updated validateWithdraw signature to include exchange parameter.
Logger & Telemetry
src/helpers/logger.ts, src/helpers/otel.ts
Refactored logger to use LogLayer with TsLog and OpenTelemetry transports; introduced BaseOtelSignal base class for metrics and logs providers; added OtelLogs class with OTLP support; implemented endpoint resolution and configuration utilities.
Server & Application Lifecycle
src/index.ts, src/server.ts
Integrated OtelLogs lifecycle management alongside OtelMetrics; replaced inline validateOrder calls with resolveOrderExecution for market validation; updated withdraw validation to pass exchange parameter; adjusted order creation to use resolved symbol and side.
Test Suite
test/helpers.test.ts, test/cex-broker.test.ts, test/integration.test.ts, test/index.test.ts, test/otel.test.ts, test/start-broker.test.ts, src/helpers/index.test.ts
Replaced deleted src/helpers/index.test.ts with comprehensive test/helpers.test.ts covering loadPolicy, validateWithdraw/Order/Deposit, and resolveOrderExecution; updated existing test files to reflect new policy structure and validateWithdraw signature; minor import reordering in various test files.
Minor Updates
examples/kraken-orderbook-demo.ts, scripts/gen-descriptor.ts, src/client.dev.ts
Consolidated duplicate imports, reordered import statements, and added dotenv configuration loading.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Server
    participant Helpers
    participant Exchange
    participant OtelLogs

    Client->>Server: CreateOrder request
    Server->>Helpers: resolveOrderExecution(policy, broker, cex, ...)
    
    Helpers->>Helpers: Match market patterns<br/>against policy rules
    Helpers->>Exchange: Check symbol support<br/>(direct & reverse)
    Exchange-->>Helpers: Symbol availability
    
    Helpers->>Helpers: Resolve symbol & side<br/>Apply conversion limits
    Helpers-->>Server: OrderExecutionResolution<br/>(symbol, side, amountBase)
    
    alt Resolution valid
        Server->>Exchange: Execute order<br/>with resolved params
        Exchange-->>Server: Order confirmation
        Server->>OtelLogs: Emit order event
    else Resolution invalid
        Server-->>Client: INVALID_ARGUMENT error
    end
    
    Server-->>Client: Order response
Loading
sequenceDiagram
    participant Application
    participant LogLayer
    participant TsLogTransport
    participant OTelTransport
    participant Outputs

    Application->>LogLayer: log.info(message)
    
    LogLayer->>TsLogTransport: Forward log record
    LogLayer->>OTelTransport: Forward log record<br/>(if NODE_ENV != test)
    
    TsLogTransport->>Outputs: Console/File output
    OTelTransport->>Outputs: OTLP HTTP endpoint
    
    Note over LogLayer: serializeError() for<br/>error objects
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • PR #24: Introduces initial OpenTelemetry integration changes (OtelMetrics, OtelConfig) that are extended in this PR with OtelLogs and BaseOtelSignal refactoring.
  • PR #26: Contains overlapping code-level changes to policy validation (WithdrawRuleEntry, validateWithdraw signature, resolveOrderExecution) and telemetry integration requiring coordination.

Suggested reviewers

  • victorshevtsov

🐰 Whiskers twitch with glee

Rules in arrays, patterns that dance,
Logs flow freely through transport's trance,
Orders execute with wisdom refined,
Policy patterns perfectly aligned,
A telemetry feast—quite the advance! ✨

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch develop

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants